<!DOCTYPE html>
<html lang="zh-cn">
<#include "../include/resource-head.ftl"/>
<link rel="stylesheet" href="/themes/plugins/fileinput/css/fileinput.min.css">
<body>
<#include "../include/common-header.ftl"/>
<div class="container col-center-block">
    <div class="order-info">
        <div class="order-item">
            <div class="order-item-top">
                <strong>${orderModel.addtime?string('yyyy-MM-dd HH:mm:ss')}</strong>&nbsp;&nbsp;&nbsp;
                <span>订单号:&nbsp;${orderModel.orderno!}</span>
            </div>
            <div class="order-item-detail">
                <div class="col-xs-4">
                    <a href="/goods/detail/${orderModel.goodsId}">
                        <img src="/data/${orderModel.goodsImg!}" height="80px" width="80px">
                        <span>${orderModel.goodsName!}</span>
                    </a>
                </div>
                <div class="col-xs-1">
                    <span class="text-red">￥${orderModel.salary?string("##0.00")}</span>
                </div>
                <div class="col-xs-1">
                    <span>${orderModel.count}</span>
                </div>
                <div class="col-xs-1">
                    <span class="text-red">￥${orderModel.total?string("##0.00")}</span>
                </div>
                <div class="col-xs-1">
                    <span>${orderModel.receiveuser!}</span>
                </div>
                <div class="col-xs-2 text-center" style="border-left: 1px solid #ececec;">
                <#if orderModel.status == 0>订单取消
                <#elseif orderModel.status == 1>代付款
                <#elseif orderModel.status == 2>待发货
                <#elseif orderModel.status == 3>待收货
                <#elseif orderModel.status == 4>待评价
                <#elseif orderModel.status == 5>订单完成</#if>
                </div>
                <div class="col-xs-2" style="border-left: 1px solid #ececec; text-align: center">
                <#if orderModel.status == 1><a href="#" onclick="pay('${orderModel.id}')"
                                               class="btn btn-primary btn-sm">付款</a>
                <#elseif orderModel.status == 3><a href="#" onclick="receive('${orderModel.id}')"
                                                   class="btn btn-warning btn-sm">确认收货</a>
                <#elseif orderModel.status == 4><a href="#" class="btn btn-success btn-sm"
                                                   onclick="eval('${orderModel.id}')">去评价</a>
                <#elseif orderModel.status == 5>${orderModel.evaluatetime?string('yyyy-MM-dd HH:mm:ss')}
                </#if>
                </div>
            </div>
        </div>
        <div class="order-info-detail">
            <h4>订单信息</h4>
            <div class="order-info-box">
                <span class="col-xs-4">创建时间: ${orderModel.addtime?string('yyyy-MM-dd HH:mm:ss')}</span>
            <#if orderModel.paytime??><span
                    class="col-xs-4">支付时间: ${orderModel.paytime?string('yyyy-MM-dd HH:mm:ss')}</span></#if>
            <#if orderModel.sendtime??><span
                    class="col-xs-4">发货时间: ${orderModel.sendtime?string('yyyy-MM-dd HH:mm:ss')}</span></#if>
            <#if orderModel.receivetime??><span
                    class="col-xs-4">收货时间: ${orderModel.receivetime?string('yyyy-MM-dd HH:mm:ss')}</span></#if>
            <#if orderModel.evaluatetime??><span
                    class="col-xs-4">评价时间: ${orderModel.evaluatetime?string('yyyy-MM-dd HH:mm:ss')}</span></#if>
            </div>
            <div class="clearfix"></div><br/>
            <h4>收货信息</h4>
            <div class="order-info-box">
                <p>收货人：${orderModel.receiveuser!}</p>
                <p >收货地址：${orderModel.receiveaddress!}</p>
                <p >备注：${orderModel.remark!}</p>
            </div>
            <div class="clearfix"></div><br/>
            <h4>定制信息</h4>
            <div class="order-info-box">
                <#if orderModel.file??>
                    <img src="/data/${orderModel.file!}" width="300px">
                </#if>
            </div>
            <div class="clearfix"></div><br/>
            <h4>评价信息</h4>
            <div class="order-info-box">
                <p>评价：<#if evaluate??>${evaluate.content!}</#if></p>

                <p>商家回复：<#if evaluate??>${evaluate.reply!}</#if></p>
            </div>
        </div>
    </div>
</div>

<!-- Modal -->
<div class="modal fade bs-example-modal-sm" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">评价订单</h4>
            </div>
            <div class="modal-body">
                <form action="/evaluate/save" method="post">
                    <input type="hidden" value="" id="orderId" name="orderId"/>
                    <textarea class="form-control" name="content" cols="5" rows="5" id="content"></textarea>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="submit" class="btn btn-primary" onclick="evaluate_submit()">提交评价</button>
            </div>
        </div>
    </div>
</div>

<#include "../include/common-foot.ftl"/>
</body>
<#include "../include/resource-script.ftl"/>
<script>
    function pay(id) {
        if (confirm("确定要付款吗？")) {
            location.href = "/order/pay?id=" + id;
        }
    }
    function receive(id) {
        if (confirm("确定已经收到了吗？")) {
            location.href = "/order/receive?id=" + id;
        }
    }
    function eval(id) {
        $("#orderId").val(id);
        $("#myModal").modal("show");
    }
    function evaluate_submit() {
        if ($("#content").val().length == 0) {
            alert("请输入评价内容");
        } else {
            $("form").submit();
        }
    }
</script>
</html>